<template>
  <div class="anchor">
    <h6 @click="goback()"><van-icon name="arrow-left" /></h6>
    <van-index-bar>
      <div class="indexBar" v-for="(arr,key) in cityObj" :key="key">
        <van-index-anchor :index="key" />
        <van-cell v-for="item in arr" :key="item.code" :title="item.name" @click="anchor(item.name)"/>
      </div>
    </van-index-bar>
  </div>
</template>

<script>
import axios from "../../utils/request";
export default {
  data() {
    return {
      cityObj: {}
    };
  },
  async created() {
    let res = await axios.get("/api/list");
    this.cityObj = res.data.data;
  },
  methods:{
    goback(){
      this.$router.go(-1);
    },
    anchor(item){
      localStorage.setItem('name',item);
      this.$router.go(-1);
    }
  }
};
</script>

<style>
</style>